<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
    <title>Title</title>
    <link rel="stylesheet" th:href="@{./layui/css/layui.css}" media="all">
    <script th:src="@{/echarts/jquery-1.11.1.min.js}"></script>
    <script th:src="@{./layui/layui.js}" charset="utf-8"></script>
    <script th:src="@{/echarts/echarts.min.js}"></script>
</head>
<body class="childrenBody">
<div>
<!--layui公共模块，就是边上的框架-->
<!--<div th:include="commonmenu :: menu"></div>-->
<!--<div class="layui-body">-->
    <!-- 内容主体区域 -->
    <div style="padding: 15px;">
        <!--  为echarts准备的dom  -->
        <div id="main" style="width: 900px; height: 700px"></div>
    </div>
</div>
<script type="text/javascript">

    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));
    // window.dataList = [];
    var datalist = [];
    option = {
        title: {
            text: 'Stacked Line'
        },
        tooltip: {
            trigger: 'axis'
        },
        legend: {
            data: ['确诊人数', '隔离人数', '治愈人数', '死亡人数', '疑似病例']
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        toolbox: {
            feature: {
                saveAsImage: {}
            }
        },
        xAxis: {
            type: 'category',
            boundaryGap: false,
            data: ['最近1天', '最近2天', '最近3天', '最近4天', '最近5天', '最近6天', '最近7天']
        },
        yAxis: {
            type: 'value'
        }
    };

    $.ajax({
        url: "/queryLine",
        dataType: "json",
        success: function (data) {
            // for (let i in data) {datalist[i] = data[i];}
            myChart.setOption({
                series: [
                    {
                        name: '确诊人数',
                        type: 'line',
                        stack: 'Total',
                        data: data.confirmList
                    },
                    {
                        name: '隔离人数',
                        type: 'line',
                        stack: 'Total',
                        data: data.isolationList
                    },
                    {
                        name: '治愈人数',
                        type: 'line',
                        stack: 'Total',
                        data: data.cureList
                    },
                    {
                        name: '死亡人数',
                        type: 'line',
                        stack: 'Total',
                        data: data.deadList
                    },
                    {
                        name: '疑似病例',
                        type: 'line',
                        stack: 'Total',
                        data: data.similarList
                    }
                ]
            })
        }
    });

    // 使用刚指定的配置项和数据显示图表。
    myChart.setOption(option);
</script>

</body>
</html>